using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class buetboss : MonoBehaviour
{
    public float speed;
    public GameObject explosionPrefab;
    new private Rigidbody2D rigidbody;

    void Awake()
    {
        rigidbody = GetComponent<Rigidbody2D>();
    }

    public void SetSpeed(Vector2 direction)
    {
        rigidbody.velocity = direction * speed;
    }

    void Update()
    {

    }

    private void OnTriggerEnter2D(Collider2D other)
    {

        //Debug.Log("PushObject begin....");
        if (other.CompareTag("Player"))
        {
            //Debug.Log("PushObject player....");
            GameObject exp = ObjectPool.Instance.GetObject(explosionPrefab);
            exp.transform.position = transform.position;


            ObjectPool.Instance.PushObject(gameObject);
            other.gameObject.SendMessage("BeHit", 1f);

            Destroy(this.gameObject);
            if (!tankstart.tankstart_Instance.Startwo)
            {
                GameManager.gameManager_Instance.GameOver();
            }
            if (tankstart.tankstart_Instance.Startwo)
            {
                GameManager.gameManager_Instance.GameOvers();
            }
        }
        else if (other.CompareTag("AriWall"))
        //if (other.CompareTag("AriWall"))
        {
            //Debug.Log("PushObject AirWall....");
            GameObject exp = ObjectPool.Instance.GetObject(explosionPrefab);
            exp.transform.position = transform.position;


            ObjectPool.Instance.PushObject(gameObject);
        }
        else if (other.CompareTag("Wall"))
        //if (other.CompareTag("Wall"))
        {
            //Debug.Log("PushObject Wall....");
            GameObject exp = ObjectPool.Instance.GetObject(explosionPrefab);
            exp.transform.position = transform.position;


            ObjectPool.Instance.PushObject(gameObject);
            Destroy(other.gameObject);
        }
        else if (other.CompareTag("Walls"))
        //if (other.CompareTag("Walls"))
        {
            //Debug.Log("PushObject Walls....");
            GameObject exp = ObjectPool.Instance.GetObject(explosionPrefab);
            exp.transform.position = transform.position;


            ObjectPool.Instance.PushObject(gameObject);
            Destroy(other.gameObject);
        }
        //ObjectPool.Instance.PushObject(gameObject);
        //Debug.Log("PushObject end....");
    }
}
